﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RoboRun
{
    class CalculateNewPosition
    {
        public static void calculateNewPosition()
        {
            if (GameplayScreen.GridType.Equals("3x3"))
            {
                calculateFor3x3();
            }
            else if (GameplayScreen.GridType.Equals("4x4"))
            {
                calculateFor4x4();
            }
            GameplayScreen.debugger.Text = GameplayScreen.RobotCurrentPosition;
         
        }

        private static void calculateFor4x4()
        {
            if (GameplayScreen.RobotCurrentDirection.Equals("North"))
            {
                newPosition4x4North();
            }
            else if (GameplayScreen.RobotCurrentDirection.Equals("East"))
            {
                newPosition4x4East();
            }
            else if (GameplayScreen.RobotCurrentDirection.Equals("South"))
            {
                newPosition4x4South();
            }
            else if (GameplayScreen.RobotCurrentDirection.Equals("West"))
            {
                newPosition4x4West();
            }
        }

        private static void calculateFor3x3()
        {
            if (GameplayScreen.RobotCurrentDirection.Equals("North"))
            {
                newPosition3x3North();
            }
            else if (GameplayScreen.RobotCurrentDirection.Equals("East"))
            {
                newPosition3x3East();
            }
            else if (GameplayScreen.RobotCurrentDirection.Equals("South"))
            {
                newPosition3x3South();
            }
            else if (GameplayScreen.RobotCurrentDirection.Equals("West"))
            {
                newPosition3x3West();
            }
        }

        private static void newPosition3x3North()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "1,1";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "1,2";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "1,3";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "2,1";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
            }
           
        }

        private static void newPosition3x3East()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "1,2";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "1,3";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "3,3";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
            }

        }

        private static void newPosition3x3South()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "2,1";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "3,1";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "3,3";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
            }

        }

        private static void newPosition3x3West()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "1,1";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "1,2";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "2,1";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "3,1";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
            }

        }

        private static void newPosition4x4North()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,4":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "1,1";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "1,2";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "1,3";
                    break;
                case "2,4":
                    GameplayScreen.RobotCurrentPosition = "1,4";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "2,1";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
                case "3,4":
                    GameplayScreen.RobotCurrentPosition = "2,4";
                    break;
                case "4,1":
                    GameplayScreen.RobotCurrentPosition = "3,1";
                    break;
                case "4,2":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
                case "4,3":
                    GameplayScreen.RobotCurrentPosition = "3,3";
                    break;
                case "4,4":
                    GameplayScreen.RobotCurrentPosition = "3,4";
                    break;
               
            }

        }

        private static void newPosition4x4East()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "1,2";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "1,3";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "1,4";
                    break;
                case "1,4":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "2,4";
                    break;
                case "2,4":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "3,3";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "3,4";
                    break;
                case "3,4":
                     GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "4,1":
                    GameplayScreen.RobotCurrentPosition = "4,2";
                    break;
                case "4,2":
                    GameplayScreen.RobotCurrentPosition = "4,3";
                    break;
                case "4,3":
                    GameplayScreen.RobotCurrentPosition = "4,4";
                    break;
                case "4,4":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;


            }

        }

        private static void newPosition4x4South()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "2,1";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
                case "1,4":
                    GameplayScreen.RobotCurrentPosition = "2,4";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "3,1";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "3,3";
                    break;
                case "2,4":
                    GameplayScreen.RobotCurrentPosition = "3,4";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "4,1";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "4,2";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "4,3";
                    break;
                case "3,4":
                    GameplayScreen.RobotCurrentPosition = "4,4";
                    break;
                case "4,1":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "4,2":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "4,3":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
                case "4,4":
                    GameplayScreen.RobotCurrentPosition = "Out of Bounds";
                    break;
            }

        }

        private static void newPosition4x4West()
        {
            switch (GameplayScreen.RobotCurrentPosition)
            {
                case "1,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "1,2":
                    GameplayScreen.RobotCurrentPosition = "1,1";
                    break;
                case "1,3":
                    GameplayScreen.RobotCurrentPosition = "1,2";
                    break;
                case "1,4":
                     GameplayScreen.RobotCurrentPosition = "1,3";
                    break;
                case "2,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "2,2":
                    GameplayScreen.RobotCurrentPosition = "2,1";
                    break;
                case "2,3":
                    GameplayScreen.RobotCurrentPosition = "2,2";
                    break;
                case "2,4":
                    GameplayScreen.RobotCurrentPosition = "2,3";
                    break;
                case "3,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "3,2":
                    GameplayScreen.RobotCurrentPosition = "3,1";
                    break;
                case "3,3":
                    GameplayScreen.RobotCurrentPosition = "3,2";
                    break;
                case "3,4":
                    GameplayScreen.RobotCurrentPosition = "3,3";
                    break;
                case "4,1":
                    GameplayScreen.RobotCurrentPosition = "Out Of Bounds";
                    break;
                case "4,2":
                    GameplayScreen.RobotCurrentPosition = "4,1";
                    break;
                case "4,3":
                    GameplayScreen.RobotCurrentPosition = "4,2";
                    break;
                case "4,4":
                    GameplayScreen.RobotCurrentPosition = "4,3";
                    break;
            }

        }
    }
}
